// stores/commentPluginStore.ts
import { defineStore } from 'pinia'
import { CommentPlugin } from '@/tiptap/extensions/CommentPlugin'
import type { Plugin } from 'prosemirror-state'

export const useCommentPluginStore = defineStore('commentPlugin', {
  state: () => ({
    pluginInstance: null as Plugin | null,
  }),
  actions: {
    initPlugin() {
      if (!this.pluginInstance) {
        this.pluginInstance = CommentPlugin()
      }
    },
    getPlugin() {
      this.initPlugin()
      return this.pluginInstance
    }
  }
})
